<template>
  <div>
    <h1>用户管理</h1>
    <template>
      <el-table :data="users" style="width: 100%" border>
        <el-table-column prop="id" label="id" width="180"> </el-table-column>
        <el-table-column prop="username" label="用户名" width="180">
        </el-table-column>
        <el-table-column prop="email" label="邮箱"> </el-table-column>
        <el-table-column prop="phone" label="电话"> </el-table-column>
        <el-table-column
          prop="createTime"
          label="注册时间"
          :formatter="a"
        ></el-table-column>
      </el-table>
    </template>
    <fenyeqi
      :total="fenye.total"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    />
    <!-- 分页 -->
  </div>
</template>

<script>
import { userlist } from "../../../http/http";
import fenyeqi from "../../../components/fenyeqi";
import time from "../../../uilts/time";
export default {
  name: "",
  components: {
    fenyeqi,
  },
  props: [],
  data() {
    return {
      // 用户数据
      users: [],
      // 分页
      fenye: {
        pagesize: 3,
        pagenum: 1,
        total: 1,
      },
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    this.userlist();
  },
  methods: {
    // 获取用户列表
    async userlist() {
      const { data: res } = await userlist(this.fenye);
      this.fenye.total = res.data.total;
      this.users = res.data.list;
      console.log(res);
    },
    handleSizeChange(size) {
      console.log(size);
      this.fenye.pagesize = size;
      this.userlist();
    },
    handleCurrentChange(page) {
      this.fenye.pagenum = page;
      this.userlist();
    },
    // 时间转换
    a(row, column, cellValue, index) {
      let b = time(row.createTime);
      return b
    },
  },
};
</script>

<style lang='scss' scoped>
</style>
